﻿using System;
using System.Collections.Generic;
using Bingosoft.Core;
using Bingosoft.Core.Ioc;
using Bingosoft.Modules.SecurityConsole.Common.Helper;
using Bingosoft.Modules.SecurityConsole.Role;
using Bingosoft.RestService.Attributes;

namespace Bingosoft.Modules.SecurityConsole.Common.FunctionControl.ListSelect
{
   [Service("RoleInheritListSelectService")]
   public class RoleInheritListSelectService:IListSelectService   
    {
       [ServiceMethod]
        public bool Save(string oldIds, string oldNames, string newIds, string newNames, IDictionary<string, object> parameters)
        {
            String[] newIdsString = newIds.Split(',');
            string roleId = DictionaryHelper.GetParamString(parameters, "RoleId");
            return GetRoleService().AddRolesForInherit(roleId, newIdsString);
        }

        private static RoleService GetRoleService()
        {
            IObjectContainer container = App.ObjectContainer;
            RoleService service = container.GetObject<RoleService>("RoleService");
            return service;
        }
    }
}
